﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using PessMvc;
using PessMvc.Helpers;


namespace PessMvc.CustomAttributes
{
    public class LogSessionActivityAttribute : ActionFilterAttribute
    {
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            try
            {
                Utility.RecordPageAccess(
                    filterContext.HttpContext.User.Identity.Name,
                    filterContext.Controller.ToString(),
                    filterContext.ActionDescriptor.ActionName,
                    filterContext.HttpContext.Request.UserHostAddress);
            }
            catch
            {
                // Don't raise any exceptions if the logging fails.

            }

            base.OnActionExecuting(filterContext);
        }
    }
}